﻿<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="RequiredTextBox_Test._Default" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Required Field Check</title>
    <style type="text/css">
        .invalidtextbox{background-color: #ff9999;}
        .invalidlabel{color: red;}
    </style>
     <script type="text/javascript">
        function showalert()
        {
            try
            { 
                if(!Page_IsValid && Page_ValidationActive)
                {
                    alert('Please correct the field(s) highlighted in red.');
                }
            }
            catch(e){}
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
        <asp:ScriptManager runat="server" ID="scriptManager"></asp:ScriptManager>
        <div>
            <asp:Label runat="server" ID="label" Text="*Name:"/>
            <asp:TextBox runat="server" ID="textbox"/>
            <asp:RequiredFieldValidator runat="server" ID="rfvTextbox" ControlToValidate="textbox"/>
            <val:RequiredFieldExtender runat="server" TargetControlID="rfvTextbox" TargetLabelID="label" 
                InvalidLabelCssClass="invalidlabel" InvalidTextBoxCssClass="invalidtextbox" />
            <asp:Button runat="server" ID="button" Text="Go" />
        </div>
        <asp:CustomValidator runat="server" ClientValidationFunction="showalert" ID="alert" /> 
        
        <!-- Test a Custom Control with embed validator, label, and extension -->
        <controls:SmartTextBox runat="server" ID="SmartBox" />
    </form>
</body>
</html>
